package com.iflytek.universitymanagement.common;

import lombok.AllArgsConstructor;
import lombok.Data;

//@Data
//@AllArgsConstructor
public class Result<T> {

    private int code;  // 响应码
    private String message;  // 响应信息
    private T data;  // 数据

    // 构造方法
    public Result(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    // 成功的静态方法
    public static <T> Result<T> success(T data) {
        return new Result<>(200, "成功", data);
    }

    // 失败的静态方法
    public static <T> Result<T> error(String message) {
        return new Result<>(500, message, null);
    }

    // getter 和 setter
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
